package com.aishua.aishuawallet.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.aishua.aishuawallet.R;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by aishua on 2018/4/3.
 */

public class FindAdapter extends RecyclerView.Adapter<FindAdapter.MyDeviceViewHoler> {

    private Context mContext;
    private List deviceinfoList;

    public FindAdapter(Context mContext, ArrayList deviceinfoList) {
        this.mContext = mContext;
        this.deviceinfoList = deviceinfoList;
    }

    @Override
    public MyDeviceViewHoler onCreateViewHolder(ViewGroup parent, int viewType) {

        View view = LayoutInflater.from(mContext).inflate(R.layout.view_find, parent, false);

        return new MyDeviceViewHoler(view);

    }

    @Override
    public void onBindViewHolder(MyDeviceViewHoler holder, final int position) {

        holder.displayView(position);
        holder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                onRecycleViewClickListener.onRecycleViewClick(position);
            }
        });

    }

    @Override
    public int getItemCount() {
        if (null == deviceinfoList || deviceinfoList.size() == 0) {

            return 0;
        }
        return deviceinfoList.size();

//        return  3;
    }

    public class MyDeviceViewHoler extends RecyclerView.ViewHolder {

        private ImageView img_find;
        private TextView tv_title;
        private TextView tv_content;
        private TextView tv_time;

        public MyDeviceViewHoler(View itemView) {
            super(itemView);
            img_find = itemView.findViewById(R.id.img_find);
            tv_title = itemView.findViewById(R.id.tv_title);
            tv_content = itemView.findViewById(R.id.tv_content);
            tv_time = itemView.findViewById(R.id.tv_time);
        }

        public void displayView(int position) {

//        String bock_id = deviceinfoList.get(position).getIotId();
//        String imei = deviceinfoList.get(position).getImei();
        }

    }


    public void setonRecycleViewClickListener(onRecycleViewClickListener onRccycleViewLongClickListener) {
        this.onRecycleViewClickListener = onRccycleViewLongClickListener;
    }

    public void setOnRccycleViewLongClickListener(onRccycleViewLongClickListener onRccycleViewLongClickListener) {

        this.onRccycleViewLongClickListener = onRccycleViewLongClickListener;
    }

    private onRecycleViewClickListener onRecycleViewClickListener;
    private onRccycleViewLongClickListener onRccycleViewLongClickListener;

    public interface onRecycleViewClickListener {

        public void onRecycleViewClick(int position);
    }

    public interface onRccycleViewLongClickListener {

        public void onRccycleViewLongClick();
    }
}